home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form BitmapForm
- Caption = "GetBitmapBits"
- ClientHeight = 2100
- ClientLeft = 2280
- ClientTop = 1815
- ClientWidth = 3180
- Height = 2790
- Left = 2220
- LinkTopic = "Form1"
- ScaleHeight = 2100
- ScaleWidth = 3180
- Top = 1185
- Width = 3300
- Begin VB.PictureBox Pict3
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- Height = 1020
- Left = 2160
- Picture = "GETBITS.frx":0000
- ScaleHeight = 64
- ScaleMode = 3 'Pixel
- ScaleWidth = 64
- TabIndex = 8
- Top = 240
- Width = 1020
- End
- Begin VB.PictureBox Pict2
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- Height = 1020
- Left = 1080
- Picture = "GETBITS.frx":1092
- ScaleHeight = 64
- ScaleMode = 3 'Pixel
- ScaleWidth = 64
- TabIndex = 7
- Top = 240
- Width = 1020
- End
- Begin VB.PictureBox Pict1
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- Height = 1020
- Left = 0
- Picture = "GETBITS.frx":2124
- ScaleHeight = 64
- ScaleMode = 3 'Pixel
- ScaleWidth = 64
- TabIndex = 6
- Top = 240
- Width = 1020
- End
- Begin VB.CommandButton CmdColors
- Caption = "Colors"
- Height = 375
- Left = 2355
- TabIndex = 5
- Top = 1680
- Width = 615
- End
- Begin VB.CommandButton CmdCheck
- Caption = "Check"
- Height = 375
- Left = 1635
- TabIndex = 4
- Top = 1680
- Width = 615
- End
- Begin VB.CommandButton CmdWave
- Caption = "Wave"
- Height = 375
- Left = 915
- TabIndex = 3
- Top = 1680
- Width = 615
- End
- Begin VB.CommandButton CmdBlank
- Caption = "Blank"
- Height = 375
- Left = 195
- TabIndex = 1
- Top = 1680
- Width = 615
- End
- Begin VB.PictureBox Original
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- Height = 1020
- Left = 3000
- Picture = "GETBITS.frx":31B6
- ScaleHeight = 64
- ScaleMode = 3 'Pixel
- ScaleWidth = 64
- TabIndex = 0
- Top = 1680
- Visible = 0 'False
- Width = 1020
- End
- Begin VB.Label Label1
- Alignment = 2 'Center
- Caption = "Line"
- Height = 255
- Index = 2
- Left = 2160
- TabIndex = 13
- Top = 0
- Width = 975
- End
- Begin VB.Label Label1
- Alignment = 2 'Center
- Caption = "GetBitmapBits"
- Height = 255
- Index = 1
- Left = 1080
- TabIndex = 12
- Top = 0
- Width = 975
- End
- Begin VB.Label Label1
- Alignment = 2 'Center
- Caption = "Line/Refresh"
- Height = 255
- Index = 0
- Left = 0
- TabIndex = 11
- Top = 0
- Width = 975
- End
- Begin VB.Label Time2
- BorderStyle = 1 'Fixed Single
- Height = 255
- Left = 1080
- TabIndex = 10
- Top = 1320
- Width = 1020
- End
- Begin VB.Label Time1
- BorderStyle = 1 'Fixed Single
- Height = 255
- Left = 0
- TabIndex = 9
- Top = 1320
- Width = 1020
- End
- Begin VB.Label Time3
- BorderStyle = 1 'Fixed Single
- Height = 255
- Left = 2160
- TabIndex = 2
- Top = 1320
- Width = 1020
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuFileExit
- Caption = "E&xit"
- End
- End
- Attribute VB_Name = "BitmapForm"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub CmdWave_Click()
- Const AMP = 3
- Const PER = 5
- Dim start_time As Single
- Dim stop_time As Single
- Dim hbm As Integer
- Dim bm As BITMAP
- Dim status As Integer
- Dim bytes() As Byte
- Dim i As Integer
- Dim j As Integer
- Dim k As Integer
- Dim wid As Integer
- Dim hgt As Integer
- CmdBlank.Enabled = False
- CmdWave.Enabled = False
- CmdCheck.Enabled = False
- CmdColors.Enabled = False
- Time1.Caption = ""
- Time2.Caption = ""
- Time3.Caption = ""
- Pict1.Picture = Original.Image
- Pict2.Picture = Original.Image
- Pict3.Picture = Original.Image
- MousePointer = vbHourglass
- Refresh
- ' ***************************************
- ' Wave picture 1 using PSet with refresh.
- ' ***************************************
- start_time = Timer()
- For i = AMP To Pict1.ScaleHeight - AMP Step 3
- For j = 0 To Pict1.ScaleWidth - 1
- k = AMP * Cos(j / PER)
- Pict1.PSet (j, i + k), vbBlack
- Next j
- Pict1.Refresh
- Next i
- stop_time = Timer()
- Time1.Caption = Format$(stop_time - start_time, "0.00000")
- Time1.Refresh
- ' *****************************
- ' Wave picture 2 using SetBits.
- ' *****************************
- start_time = Timer()
- hbm = Pict2.Image
- ' See how big it is.
- status = GetObject(hbm, BITMAP_SIZE, bm)
- ' Get the bits.
- wid = bm.bmWidthBytes
- hgt = bm.bmHeight
- ReDim bytes(1 To wid, 1 To hgt)
- status = GetBitmapBits(hbm, wid * hgt, bytes(1, 1))
- ' Make the wave.
- For i = AMP + 1 To hgt - AMP Step 3
- For j = 1 To wid
- k = AMP * Cos(j / PER)
- bytes(j, i + k) = 0
- Next j
- Next i
- ' Set the bits.
- status = SetBitmapBits(hbm, wid * hgt, bytes(1, 1))
- Pict2.Refresh
- stop_time = Timer()
- Time2.Caption = Format$(stop_time - start_time, "0.00000")
- Time2.Refresh
- ' ******************************************
- ' Wave picture 3 using PSet without refresh.
- ' ******************************************
- start_time = Timer()
- For i = AMP To Pict3.ScaleHeight - AMP Step 3
- For j = 0 To Pict3.ScaleWidth - 1
- k = AMP * Cos(j / PER)
- Pict3.PSet (j, i + k), vbBlack
- Next j
- Next i
- Pict3.Refresh
- stop_time = Timer()
- Time3.Caption = Format$(stop_time - start_time, "0.00000")
- CmdBlank.Enabled = True
- CmdWave.Enabled = True
- CmdCheck.Enabled = True
- CmdColors.Enabled = True
- MousePointer = vbDefault
- End Sub
- Private Sub CmdCheck_Click()
- Dim start_time As Single
- Dim stop_time As Single
- Dim hbm As Integer
- Dim bm As BITMAP
- Dim status As Integer
- Dim bytes() As Byte
- Dim i As Integer
- Dim j As Integer
- Dim wid As Integer
- Dim hgt As Integer
- CmdBlank.Enabled = False
- CmdWave.Enabled = False
- CmdCheck.Enabled = False
- CmdColors.Enabled = False
- Time1.Caption = ""
- Time2.Caption = ""
- Time3.Caption = ""
- Pict1.Picture = Original.Image
- Pict2.Picture = Original.Image
- Pict3.Picture = Original.Image
- MousePointer = vbHourglass
- Refresh
- ' ****************************************
- ' Check picture 1 using PSet with refresh.
- ' ****************************************
- start_time = Timer()
- wid = Pict1.ScaleWidth - 1
- hgt = Pict1.ScaleHeight - 1
- For i = 0 To hgt Step 2
- Pict1.Line (0, i)-(wid, i)
- Pict1.Refresh
- Next i
- For i = 0 To wid Step 2
- Pict1.Line (i, 0)-(i, hgt)
- Pict1.Refresh
- Next i
- stop_time = Timer()
- Time1.Caption = Format$(stop_time - start_time, "0.00000")
- Time1.Refresh
- ' ******************************
- ' Check picture 2 using SetBits.
- ' ******************************
- start_time = Timer()
- hbm = Pict2.Image
- ' See how big it is.
- status = GetObject(hbm, BITMAP_SIZE, bm)
- ' Get the bits.
- wid = bm.bmWidthBytes
- hgt = bm.bmHeight
- ReDim bytes(1 To wid, 1 To hgt)
- status = GetBitmapBits(hbm, wid * hgt, bytes(1, 1))
- ' Check it.
- For i = 1 To hgt Step 2
- For j = 1 To wid
- bytes(j, i) = 0
- Next j
- Next i
- For i = 1 To wid Step 2
- For j = 1 To hgt
- bytes(i, j) = 0
- Next j
- Next i
- ' Set the bits.
- status = SetBitmapBits(hbm, wid * hgt, bytes(1, 1))
- Pict2.Refresh
- stop_time = Timer()
- Time2.Caption = Format$(stop_time - start_time, "0.00000")
- Time2.Refresh
- ' ******************************************
- ' Wave picture 3 using PSet without refresh.
- ' ******************************************
- start_time = Timer()
- wid = Pict3.ScaleWidth - 1
- hgt = Pict3.ScaleHeight - 1
- For i = 0 To hgt Step 2
- Pict3.Line (0, i)-(wid, i)
- Next i
- For i = 0 To wid Step 2
- Pict3.Line (i, 0)-(i, hgt)
- Next i
- Pict3.Refresh
- stop_time = Timer()
- Time3.Caption = Format$(stop_time - start_time, "0.00000")
- CmdBlank.Enabled = True
- CmdWave.Enabled = True
- CmdCheck.Enabled = True
- CmdColors.Enabled = True
- MousePointer = vbDefault
- End Sub
- Sub CmdColors_Click()
- Static running As Boolean
- Dim hbm As Integer
- Dim bm As BITMAP
- Dim status As Integer
- Dim bytes() As Byte
- Dim i As Integer
- Dim j As Integer
- Dim wid As Integer
- Dim hgt As Integer
- Dim color As Integer
- If running Then
- running = False
- CmdColors.Enabled = False
- Exit Sub
- End If
- CmdBlank.Enabled = False
- CmdWave.Enabled = False
- CmdCheck.Enabled = False
- CmdColors.Caption = "Stop"
- running = True
- Time1.Caption = ""
- Time2.Caption = ""
- Time3.Caption = ""
- Pict1.Picture = Original.Image
- Pict2.Picture = Original.Image
- Pict3.Picture = Original.Image
- MousePointer = vbHourglass
- Refresh
-
- ' Get the bits.
- hbm = Pict2.Image
- status = GetObject(hbm, BITMAP_SIZE, bm)
- wid = bm.bmWidthBytes
- hgt = bm.bmHeight
- ReDim bytes(1 To wid, 1 To hgt)
- status = GetBitmapBits(hbm, wid * hgt, bytes(1, 1))
- wid = bm.bmWidthBytes
- ' Display the colors in the palette.
- For color = 0 To 255
- If Not running Then Exit For
- Time2.Caption = Format$(color)
- For i = 1 To wid
- For j = 1 To hgt
- If bytes(i, j) <> 255 Then _
- bytes(i, j) = color
- Next j
- Next i
- status = SetBitmapBits(hbm, wid * hgt, bytes(1, 1))
- Pict2.Refresh
-
- ' Waste a little time. You may need to
- ' adjust this for your computer.
- For i = 1 To 1000
- DoEvents
- Next i
- Next color
- running = False
- Time2.Caption = ""
- Pict2.Picture = Original.Image
- CmdColors.Caption = "Colors"
- CmdBlank.Enabled = True
- CmdWave.Enabled = True
- CmdCheck.Enabled = True
- CmdColors.Enabled = True
- MousePointer = vbDefault
- End Sub
- Private Sub CmdBlank_Click()
- Dim start_time As Single
- Dim stop_time As Single
- Dim hbm As Integer
- Dim bm As BITMAP
- Dim status As Integer
- Dim bytes() As Byte
- Dim i As Integer
- Dim j As Integer
- Dim wid As Integer
- Dim hgt As Integer
- CmdBlank.Enabled = False
- CmdWave.Enabled = False
- CmdCheck.Enabled = False
- CmdColors.Enabled = False
- Time1.Caption = ""
- Time2.Caption = ""
- Time3.Caption = ""
- Pict1.Picture = Original.Image
- Pict2.Picture = Original.Image
- Pict3.Picture = Original.Image
- MousePointer = vbHourglass
- Refresh
- ' ****************************************
- ' Blank picture 1 using PSet with refresh.
- ' ****************************************
- start_time = Timer()
- For i = 0 To Pict1.ScaleHeight - 1
- For j = 0 To Pict1.ScaleWidth - 1
- Pict1.PSet (j, i), vbBlack
- Next j
- Pict1.Refresh
- Next i
- stop_time = Timer()
- Time1.Caption = Format$(stop_time - start_time, "0.00000")
- Time1.Refresh
- ' ******************************
- ' Blank picture 2 using SetBits.
- ' ******************************
- start_time = Timer()
- hbm = Pict2.Image
- ' See how big it is.
- status = GetObject(hbm, BITMAP_SIZE, bm)
- ' Get the bits.
- wid = bm.bmWidthBytes
- hgt = bm.bmHeight
- ReDim bytes(1 To wid, 1 To hgt)
- status = GetBitmapBits(hbm, wid * hgt, bytes(1, 1))
- ' Set all bits to color 0.
- For i = 1 To hgt
- For j = 1 To wid
- bytes(i, j) = 0
- Next j
- Next i
- ' Set the bits.
- status = SetBitmapBits(hbm, wid * hgt, bytes(1, 1))
- Pict2.Refresh
- stop_time = Timer()
- Time2.Caption = Format$(stop_time - start_time, "0.00000")
- Time2.Refresh
- ' *******************************************
- ' Blank picture 3 using PSet without refresh.
- ' *******************************************
- start_time = Timer()
- For i = 0 To Pict3.ScaleWidth - 1
- For j = 0 To Pict3.ScaleHeight - 1
- Pict3.PSet (i, j), vbBlack
- Next j
- Next i
- Pict3.Refresh
- stop_time = Timer()
- Time3.Caption = Format$(stop_time - start_time, "0.00000")
- CmdBlank.Enabled = True
- CmdWave.Enabled = True
- CmdCheck.Enabled = True
- CmdColors.Enabled = True
- MousePointer = vbDefault
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- End
- End Sub
- Private Sub mnuFileExit_Click()
- Unload Me
- End Sub
-